package com.urms.mapper;

import com.urms.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;


@Mapper
public interface UserMapper {

    // 根据手机号查询学生信息
    @Select("select * from student where phone = #{phone}")
    User queryStudentByPhone(String phone);


    // 注册学生
    @Insert("insert into student ( username, password,phone , regTime) value (#{username},#{password},#{phone},now())")
    void insertStudent(User user);


    // 根据手机号查询管理员信息
    @Select("select * from admin where phone = #{phone}")
    User queryAdminByPhone(String phone);

    // 注册管理员
    @Insert("insert into admin (username, password,phone, role,regTime) value (#{username},#{password},#{phone},#{role},now())")
    void insertAdmin(User user);

    // 根据用户名查询用户信息
    @Select("select * from student where id = #{id}")
    User queryStudentById(int id);

    // 根据用户名查询管理员信息
    @Select("select * from admin where id = #{id}")
    User queryAdminById(int id);
}
